package com.css.project.infoInnovation.service.impl;

import java.util.Date;
import java.util.List;

import com.css.common.utils.SecurityUtils;
import com.css.framework.security.LoginUser;
import com.css.project.system.domain.SysRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.css.project.infoInnovation.mapper.InformationInnovationScheduleMapper;
import com.css.project.infoInnovation.domain.InformationInnovationSchedule;
import com.css.project.infoInnovation.service.IInformationInnovationScheduleService;

/**
 * 信创进度Service业务层处理
 * 
 * @author css
 * @date 2020-05-14
 */
@Service
public class InformationInnovationScheduleServiceImpl implements IInformationInnovationScheduleService 
{
    @Autowired
    private InformationInnovationScheduleMapper informationInnovationScheduleMapper;

    /**
     * 查询信创进度
     * 
     * @param id 信创进度ID
     * @return 信创进度
     */
    @Override
    public InformationInnovationSchedule selectInformationInnovationScheduleById(Long id)
    {
        return informationInnovationScheduleMapper.selectInformationInnovationScheduleById(id);
    }

    /**
     * 查询信创进度列表
     * 
     * @param informationInnovationSchedule 信创进度
     * @return 信创进度
     */
    @Override
    public List<InformationInnovationSchedule> selectInformationInnovationScheduleList(InformationInnovationSchedule informationInnovationSchedule)
    {
        LoginUser cu = SecurityUtils.getLoginUser();
        List<SysRole> roles = cu.getUser().getRoles();
        for(int i=0;i<roles.size();i++){
            if("xclr".equals(roles.get(i).getRoleKey())){
                informationInnovationSchedule.setCreateBy(cu.getUsername());
            }
        }
        return informationInnovationScheduleMapper.selectInformationInnovationScheduleList(informationInnovationSchedule);
    }

    /**
     * 新增信创进度
     * 
     * @param informationInnovationSchedule 信创进度
     * @return 结果
     */
    @Override
    public int insertInformationInnovationSchedule(InformationInnovationSchedule informationInnovationSchedule)
    {
        LoginUser cu = SecurityUtils.getLoginUser();
        informationInnovationSchedule.setCreateTime(new Date());
        informationInnovationSchedule.setCreateBy(cu.getUsername());
        informationInnovationSchedule.setUpdateTime(new Date());
        informationInnovationSchedule.setUpdateBy(cu.getUsername());
        return informationInnovationScheduleMapper.insertInformationInnovationSchedule(informationInnovationSchedule);
    }

    @Override
    public int insertList(List<InformationInnovationSchedule> list) {
        return informationInnovationScheduleMapper.insertList(list);
    }

    /**
     * 修改信创进度
     * 
     * @param informationInnovationSchedule 信创进度
     * @return 结果
     */
    @Override
    public int updateInformationInnovationSchedule(InformationInnovationSchedule informationInnovationSchedule)
    {
        LoginUser cu = SecurityUtils.getLoginUser();
        informationInnovationSchedule.setUpdateTime(new Date());
        informationInnovationSchedule.setUpdateBy(cu.getUsername());
        return informationInnovationScheduleMapper.updateInformationInnovationSchedule(informationInnovationSchedule);
    }

    /**
     * 批量删除信创进度
     * 
     * @param ids 需要删除的信创进度ID
     * @return 结果
     */
    @Override
    public int deleteInformationInnovationScheduleByIds(Long[] ids)
    {
        return informationInnovationScheduleMapper.deleteInformationInnovationScheduleByIds(ids);
    }

    /**
     * 删除信创进度信息
     * 
     * @param id 信创进度ID
     * @return 结果
     */
    @Override
    public int deleteInformationInnovationScheduleById(Long id)
    {
        return informationInnovationScheduleMapper.deleteInformationInnovationScheduleById(id);
    }
}
